package com.intelligentpension.kotlinbluetoothprint.adapter

import android.annotation.SuppressLint
import android.bluetooth.BluetoothDevice
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.intelligentpension.kotlinbluetoothprint.R
import com.intelligentpension.kotlinbluetoothprint.bean.BluethBean

/**
 * 版权：点赞 版权所有
 * author :赵航
 * @e-mail: zhaohangcn@gmail.com
 * time：2022/4/2
 * describe ：
 */
class BluetoothItemAdapter(layout: Int, list: MutableList<BluethBean>) :
    BaseQuickAdapter<BluethBean, BaseViewHolder>(layout, list) {
    @SuppressLint("MissingPermission")
    override fun convert(holder: BaseViewHolder, item: BluethBean) {

        var state = item.dev.bondState;
        var msgState = when (state) {
            BluetoothDevice.BOND_NONE -> {
                "未配对"
            }
            else -> {
                "已配对"
            }
        }

        holder.setText(R.id.name_text, item.name + "===" + msgState)
        holder.setText(R.id.address_text, item.address)
    }
}